<?php if (!defined('THINK_PATH')) exit(); /*a:3:{s:77:"D:\program\phpStudy\WWW\2188\public/../application/admin\view\user_index.html";i:1550421731;s:70:"D:\program\phpStudy\WWW\2188\application\admin\view\public_header.html";i:1543251271;s:68:"D:\program\phpStudy\WWW\2188\application\admin\view\public_left.html";i:1548998499;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>后台管理</title>

    <script src="/static/jquery-2.js"></script>
    <script src="/static/layui/layui.js"></script>
    <link rel="stylesheet" href="/static/layui/css/layui.css">
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">

    <div class="layui-header">
    <div class="layui-logo" style="width: 400px;"> 短期胰岛素泵强化治疗血糖监算器 后台管理</div>

    <ul class="layui-nav layui-layout-right">
        <li class="layui-nav-item"><a href="<?php echo url('index/index'); ?>"  >后台首页</a></li>


        <li class="layui-nav-item">
            <a href="javascript:;">
                <!--<img src="http://t.cn/RCzsdCq" class="layui-nav-img">-->
                用户：<?php echo \think\Session::get('username'); ?>
            </a>

        </li>

        <li class="layui-nav-item"><a href="#" id="logout">退了</a></li>
    </ul>
</div>
    <div class="layui-side layui-bg-black">
    <div class="layui-side-scroll">
        <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
        <ul class="layui-nav layui-nav-tree"  lay-filter="test">
            <li class="layui-nav-item layui-nav-itemed">
                <a class="" href="javascript:;">治疗信息</a>
                <dl class="layui-nav-child">
                    <dd <?php if($t == 1): ?> class="layui-this" <?php endif; ?>><a href="<?php echo url('Treat/treatlist'); ?>">起始治疗方案</a></dd>
                    <dd <?php if($t == 2): ?> class="layui-this" <?php endif; ?>><a  href="<?php echo url('Treat/blood'); ?>">血糖监测</a></dd>
                    <dd <?php if($t == 3): ?> class="layui-this" <?php endif; ?>><a href="<?php echo url('Treat/beforeeating'); ?>">餐前大剂量</a></dd>

                    <dd <?php if($t == 4): ?> class="layui-this" <?php endif; ?>><a href="<?php echo url('Treat/temporary'); ?>">临时大剂量</a></dd>

                </dl>
            </li>
            <li class="layui-nav-item layui-nav-itemed">
                <a class="" href="javascript:;">用户管理</a>
                <dl class="layui-nav-child">
                    <dd <?php if($t == 5): ?> class="layui-this" <?php endif; ?>><a href="<?php echo url('Admin/index'); ?>">系统管理员列表</a></dd>
                    <dd <?php if($t == 6): ?> class="layui-this" <?php endif; ?>><a href="<?php echo url('User/index'); ?>">用户管理</a></dd>
                    <dd <?php if($t == 8): ?> class="layui-this" <?php endif; ?>><a href="<?php echo url('Data/index'); ?>">导出管理</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item layui-nav-itemed">
                <a class="" href="javascript:;">系统管理</a>
                <dl class="layui-nav-child">
                    <dd <?php if($t == 7): ?> class="layui-this" <?php endif; ?>><a href="<?php echo url('Wechat/index'); ?>">微信设置</a></dd>
                </dl>
            </li>
           <!-- <li class="layui-nav-item layui-nav-itemed">
                <a class="" href="javascript:;">评论与收藏</a>
                <dl class="layui-nav-child">
                    <dd <?php if($t == 6): ?> class="layui-this" <?php endif; ?>><a href="<?php echo url('comment/index'); ?>">评论列表</a></dd>
                    <dd <?php if($t == 7): ?> class="layui-this" <?php endif; ?>><a href="<?php echo url('collection/index'); ?>">收藏记录</a></dd>

                </dl>
            </li>-->

            <!-- <li class="layui-nav-item"><a href="">云市场</a></li>
             <li class="layui-nav-item"><a href="">发布商品</a></li>-->
        </ul>
    </div>
</div>
    <style>
        .layui-table-cell{
            height: 33px;
        }
    </style>



    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;">


            <fieldset class="layui-elem-field layui-field-title"  style="margin-top: 50px;">
                <legend>用户列表</legend>
            </fieldset>
            <form class="navbar-form form-inline" action="" method="get">
                <div class="sDiv" style="margin-top: 20px;">
                    <div class="sDiv2">
                        <div class="layui-inline">
                        <input style="width: 300px;display: block;" type="text" class="layui-input" name="keyword" placeholder="可搜索用户名" value="<?php echo $keyword; ?>">
                        </div>
                        <input class="layui-btn" type="submit" value="搜索">
                    </div>
                </div>
            </form>
			<div style="margin-top:10px;">
            <a class="layui-btn layui-btn-warm" href="<?php echo url('User/add'); ?>">新增用户</a>
                <div class="layui-inline">
                  <label class="layui-form-label">开始日期</label>
                  <div class="layui-input-inline">
                    <input type="text" name="start_date" id="start_date" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                  </div>
                </div>
                <div class="layui-inline">
                  <label class="layui-form-label">结束日期</label>
                  <div class="layui-input-inline">
                    <input type="text" name="end_date" id="end_date" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                  </div>
                </div>
            <a class="layui-btn layui-btn" id="export" href="<?php echo url('Data/asynchronous'); ?>">导出</a>
			</div>
            <table class="layui-hide" id="list"></table>



            <script>

                // 实现方法
                // @param name { String } 需要返回的属性名
                // @param arr { Array } 原始数据
                // @return ret { Array } 返回值
                function getParamValues(name, arr) {
                    var ret = []
                    for (var i = 0, len = arr.length; i < len; i++) {
                        ret.push(arr[i][name])
                    }
                    return ret
                }

                layui.use(['table','layer'], function(){
                    var table = layui.table;
                    var layer = layui.layer;

                    table.render({
                        elem: '#list'
						,limits: [10,20,30,40,50,60,70,80,90,100,150,200]
                        ,url: "<?php echo url('User/listjson',['keyword'=>$keyword]); ?>"
                        ,cols: [[
                            {type:'checkbox',width:'3%'}
                            ,{field:'uid', width:'10%', title: 'ID', sort: true}
                            ,{field:'username', width:'15%', title: '用户名'}
                            ,{field:'age', width:'15%', title: '年龄',sort: true}
                            ,{field:'height', width:'10%', title: '身高'}
                            ,{field:'weight', width: '10%', title: '体重' }
                            ,{field:'operation', minWidth: '550', title: '操作',templet: '#operation'}
                        ]]
                        ,page: true,
                        id:'tb'
                    });

                    $('#export').click(function (e) {
                        e.preventDefault();
                        var href = $(this).attr('href');
                        var checkStatus = table.checkStatus('tb'); //idTest 即为基础参数 id 对应的值
                        var start_time = $('#start_date').val();
                        var end_time = $('#end_date').val();
                        console.log(checkStatus.data) //获取选中行的数据
                        console.log(checkStatus.data.length) //获取选中行数量，可作为是否有选中行的条件
                        console.log(checkStatus.isAll ) //表格是否全选
                        $ret = getParamValues('uid',checkStatus.data).join(',');
                        console.log($ret);//获取选中行的数据


                        layer.confirm('真的要导出吗？',function (index) {

//                            layer.alert('正在导出，可以在导出管理查看');


                            if(checkStatus.data.length == 0){
                                /*var layer = layui.layer;
                                 layer.msg('你没有选中一项');
                                 return false;*/
                                $.ajax({
                                    type:'get',
                                    url:href + '?'+'start_time='+start_time+'&end_time='+end_time,
                                    success:function (res) {
//                                        layer.msg('正在导出');
                                    }
                                })

                            }else{

                                $.ajax({
                                    type:'get',
                                    url:href + '?uids='+$ret+'&start_time='+start_time+'&end_time='+end_time,
                                    success:function (res) {
//                                        layer.msg('导出成功');
                                    }
                                })



                            }


                            layer.confirm('正在导出，可以在导出管理查看,现在要跳转到导出管理查看吗？',function (i2) {


                                location.href="<?php echo url('Data/index'); ?>";
                                layer.close(i2);

                            })


                            layer.close(index);
                        });




                    })




                });
            </script>
            <script type="text/html" id="operation">
                <a class="layui-btn layui-btn-normal" href="<?php echo url('User/detail' ); ?>?uid={{d.uid}} " >详细</a>
                <a class="layui-btn layui-btn-normal" href="<?php echo url('Treat/treatment' ); ?>?uid={{d.uid}} " >起始治疗方案</a>
                <a class="layui-btn layui-btn-normal" href="<?php echo url('Treat/history' ); ?>?uid={{d.uid}} " >数据汇总</a>
                <a class="layui-btn layui-btn-normal" href="<?php echo url('Treat/bshistory' ); ?>?uid={{d.uid}} " >血糖记录</a>
                <a class="layui-btn layui-btn-danger delbtn"  onclick=" return confirm('你真的要删除这个用户吗')" href="<?php echo url('User/delete' ); ?>?uid={{d.uid}} " >删除</a>
            </script>

        </div>
    </div>


</div>

<script>

    //JavaScript代码区域
    layui.use('element', function(){
        var element = layui.element;

    });
    $('#logout').click(function (e) {
        e.preventDefault();
        layui.use('layer', function(){
            var layer = layui.layer;

            layer.confirm('你真的要退出吗？',['yes','no'],function () {
                location.href="<?php echo url('login/logout'); ?>";
            },function () {
                
            })
        });
    })

    layui.use('laydate', function(){
        var laydate = layui.laydate;
        //常规用法
        laydate.render({
            elem: '#start_date'
            ,max: 0 //7天后
        });
        laydate.render({
            elem: '#end_date'
            ,max: 0 //7天后
        });
    });




</script>

</body>
</html>